<template>
    <el-dialog title="添加信息" :visible.sync="visible" @close="setFalse">
        <el-form :model="form">
<!--            <el-form-item label="编号"   :label-width="formLabelWidth">-->
<!--                <el-input v-model="form.cid" autocomplete="off"></el-input>-->
<!--            </el-form-item>-->
            <el-form-item label="访客姓名" :label-width="formLabelWidth">
                <el-input v-model="form.vname" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="电话" :label-width="formLabelWidth">
                <el-input v-model="form.vphone" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="宿舍号" :label-width="formLabelWidth">
                <el-input v-model="form.vdormitoryid" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="楼号" :label-width="formLabelWidth">
                <el-input v-model="form.vdormbuilding" autocomplete="off"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="setFalse">取 消</el-button>
            <el-button type="primary" @click="addClass">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script>
    import instance from "@/utils/request";

    export default {
        name: "add",
            data() {
                return {
                    form: {
                    },
                    formLabelWidth: '120px'
                };
            },
            props:{
                visible:{
                    type:Boolean,
                    default:false,
                    required: true,
                }
            },
            methods:{
                setFalse() {
                    this.$emit('setAdd');
                },
                addClass(){
                    console.log(this.form);
                    instance.post("/dVisitor?",this.form).then(res=>{
                        this.form={};
                    })
                    this.setFalse();
                    this.open2();
                },
                open2() {
                    this.$message({
                        message: '添加成功',
                        type: 'success'
                    });
                },
            }

    }
</script>

<style scoped>

</style>
